<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <script type="text/javascript" src="${ctx}/appjs/hlht/hlhtDiscount.js"></script>
    <link href="${ctx}/statics/css/plugins/steps/jquery.steps.css" rel="stylesheet">
    <script type="text/javascript" src="${ctx}/libjs/plugins/steps/jquery.steps.min.js"></script>
    <style>
        .wizard-big.wizard > .content {
            min-height: 600px;
        }

        .wizard > .content > .body {
            padding-top: 1%;
        }

        .form-group {
            margin-top: 1rem;
        }

        input[type=checkbox], input[type=radio] {
            display: inline-block;
            width: 15px;
            height: 15px;
            vertical-align: text-bottom;
            margin-right: 10px;
        }

        .inlineBlock {
            display: inline-block !important;
        }

        #beginTime, #endTime {
            width: 35%;
        }

        .wizard > .content > .body label.error {
            margin: 0 1rem 0 0;
        }

        .width20 {
            width: 20% !important;
        }

        .titleFont {
            font-size: 14px;
            font-weight: 700;
        }

        .width20 {
            width: 20%;
        }

        .width10 {
            width: 10%;
        }

        .ml10 {
            margin-left: 10px;
        }

        .mt10 {
            margin-top: 10px;
        }

        .width8 {
            width: 8%;
        }

        .width170 {
            width: 170px;
        }

        .mlr {
            margin: 0 10px;
        }

        .btn {
            color: #fff !important;
        }

        .hide {
            display: none;
        }

        #beginTime, #endTime {
            width: auto;
        }

        #beginTime-error {
            display: none !important;
        }


        .form-group {
            /*display: block;*/
            margin-top: 20px !important;
        }

        .error {
            background: rgb(251, 227, 228);
            border: 1px solid #fbc2c4;
            color: #8a1f11;
        }

        /*#beginTime,#endTime{*/
        /*background-color: #fff !important;*/
        /*}*/
    </style>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>互联互通</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>编辑站点折扣</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="columns pull-left">
                        <h5 class="font-bold">编辑站点折扣</h5>
                    </div>
                    <div class="ibox-tools">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>


                <div class="ibox-content">
                    <form id="form" action="#" class="wizard-big">
                        <input type="hidden" id="tenantCode" value="${tenantDiscountPolicy.tenantCode}">
                        <input type="hidden" id="hlhtMemberId" value="${tenantDiscountPolicy.hlhtMemberId}">
                        <input type="hidden" id="discountStationId" value="${discountStationId}">
                        <input id="discountPolicyId" name="discountPolicyId" type="hidden" value="">
                        <h1>类型&时间</h1>
                        <fieldset>
                            <div class="row">
                                <div class="col-lg-8">
                                    <div class="form-group">
                                        <label class="col-sm-2">互联运营商名称 *</label>
                                        <input id="hlhtOperatorName" name="hlhtOperatorName" type="text"
                                               autocomplete="off"
                                               value="${hlhtOperatorName}"
                                               class="form-control col-sm-6" disabled>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2">折扣类型 *</label>
                                        <div class="col-sm-2 inlineBlock">
                                            <input name="discountType" type="radio" checked value="0"
                                                   autocomplete="off"
                                                   <c:if test="${tenantDiscountPolicy.discountType eq '0'}">checked</c:if>
                                                   class="form-control inlineBlock">服务费折扣
                                        </div>
                                        <%--<div class="col-sm-2 inlineBlock">--%>
                                            <%--<input name="discountType" type="radio" value="1" autocomplete="off"--%>
                                                   <%--<c:if test="${tenantDiscountPolicy.discountType eq '1'}">checked</c:if>--%>
                                                   <%--class="form-control  inlineBlock">总价折扣--%>
                                            <%--&lt;%&ndash;<input name="discountType" type="radio" checked class="form-control inlineBlock">特定价格&ndash;%&gt;--%>
                                        <%--</div>--%>
                                    </div>
                                    <%--<div class="form-group">--%>
                                    <%--<label>优惠政策说明</label>--%>
                                    <%--<input id="" name="policyDesc" type="text" autocomplete="off"--%>
                                    <%--class="form-control " placeholder="请输入优惠政策说明">--%>
                                    <%--</div>--%>
                                    <%--<div class="form-group">--%>
                                    <%--<label>打折类型下的折扣率% *</label>--%>
                                    <%--<input id="discount" name="discount" type="text" class="form-control " autocomplete="off"--%>
                                    <%--placeholder="请输入折扣率">--%>
                                    <%--</div>--%>
                                    <div class="form-group">
                                        <label class="col-sm-2">折扣时间 *</label>
                                        <div>
                                            <input id="beginTime" name="beginTime" type="text" autocomplete="off"
                                                   readonly
                                                   value="<fmt:formatDate value="${tenantDiscountPolicy.beginTime}" pattern="yyyy-MM-dd HH:mm:ss" />"
                                                   class="form-control col-sm-6   inlineBlock" autocomplete="off"
                                                   placeholder="请选择开始时间">
                                            <span>--</span>
                                            <input id="endTime" name="endTime" type="text" autocomplete="off" readonly
                                                   value="<fmt:formatDate value="${tenantDiscountPolicy.endTime}" pattern="yyyy-MM-dd HH:mm:ss" />"
                                                   class="form-control col-sm-6 inlineBlock" autocomplete="off"
                                                   placeholder="请选择结束时间">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2">备注 *</label>
                                        <div>
                                            <textarea name="remark" id="remark" cols="50"
                                                      rows="5">${tenantDiscountPolicy.policyDesc}</textarea>
                                        </div>
                                    </div>
                                    <%--<div class="col-lg-4">--%>
                                    <%--<div class="text-center">--%>
                                    <%--<div style="margin-top: 20px">--%>
                                    <%--<i class="fa fa-sign-in"--%>
                                    <%--style="font-size: 180px;color: #e5e5e5 "></i>--%>
                                    <%--</div>--%>
                                    <%--</div>--%>
                                    <%--</div>--%>
                                </div>
                            </div>
                        </fieldset>
                        <h1>时段</h1>
                        <fieldset>
                            <div class="typeBox1 <c:if test="${tenantDiscountPolicy.discountType eq '1'}">hide</c:if>">
                                <%--<h2>编辑时段价格</h2>--%>
                                <div class="row">
                                    <div class="col-lg-12">
                                        <div class="form-group disCountTypeBox1" style="display: block">
                                            <input type="radio" value="1" name="D_timeType"
                                                   <c:if test="${tenantDiscountPolicy.timeType eq '0'}">checked</c:if>
                                                   class="inlineBlock firstRadio"><label
                                                class="titleFont">采用全天标准折扣（0~1）</label>
                                            <%--<c:forEach items="${tenantDiscountPolicy.tenantDiscountTimeList}" var="bean" varStatus="index" >--%>
                                            <c:if test="${tenantDiscountPolicy.timeType eq '0'}">
                                                <c:forEach items="${tenantDiscountPolicy.tenantDiscountTimeList}"
                                                           var="bean" varStatus="index" end="0">
                                                    <div class="typeOneBox <c:if test="${tenantDiscountPolicy.timeType eq '1'}">hide</c:if>">
                                                        <span style="margin-left: 30px">服务费折扣*</span>
                                                        <input id="D_discount0" name="discount0" type="text"
                                                               value="${bean.discount}"
                                                               class="form-control inlineBlock width170" required
                                                               autocomplete="off" placeholder="请输入服务费折扣">
                                                    </div>
                                                </c:forEach>
                                            </c:if>
                                            <c:if test="${tenantDiscountPolicy.timeType eq '1'}">
                                                <div class="typeOneBox <c:if test="${tenantDiscountPolicy.timeType eq '1'}">hide</c:if>">
                                                    <span style="margin-left: 30px">服务费折扣*</span>
                                                    <input id="D_discount0" name="discount0" type="text"
                                                           value=""
                                                           class="form-control inlineBlock width170" required
                                                           autocomplete="off" placeholder="请输入服务费折扣">
                                                </div>
                                            </c:if>
                                        </div>

                                        <div class="form-group timeForm1" style="display: block">
                                            <div>
                                                <input type="radio" value="2" name="D_timeType"
                                                       <c:if test="${tenantDiscountPolicy.timeType eq '1'}">checked</c:if>
                                                       class="inlineBlock secondRadio"><label
                                                    class="titleFont">采用分时段折扣设置（需覆盖全部时段）（0~1）</label>
                                            </div>
                                            <c:if test="${tenantDiscountPolicy.timeType eq '1'}">
                                                <c:forEach items="${tenantDiscountPolicy.tenantDiscountTimeList}"
                                                           var="bean" varStatus="index">
                                                    <div name="VIPQuantuan"
                                                         class="mt10 <c:if test="${tenantDiscountPolicy.timeType eq '0'}">hide</c:if>">
                                                        <label class="ml10" style="margin-left: 30px">时段${index.index+1}:</label>
                                                        <input id="D_startPeriod${index.index+1}" name="startPeriods"
                                                               type="text"
                                                               autocomplete="off"
                                                               value="<fmt:formatDate value="${not empty bean.beginTime?bean.beginTime:'00:00:00'}" pattern="HH:mm:ss" />"
                                                               class="form-control ml10 inlineBlock width10" required
                                                               placeholder="开始时间">
                                                        <span class="mlr">--</span>
                                                        <input id="D_endPeriod${index.index+1}" name="endPeriods"
                                                               type="text" required
                                                               autocomplete="off"
                                                               value="<fmt:formatDate value="${not empty bean.endTime?bean.endTime:'00:59:59'}" pattern="HH:mm:ss" />"
                                                               class="form-control inlineBlock width10"
                                                               placeholder="结束时间">
                                                        <span class="ml10">服务费折扣*</span>
                                                        <input id="D_discounts${index.index+1}" name="discounts"
                                                               type="text" required
                                                               autocomplete="off" value="${bean.discount}"
                                                               class="form-control inlineBlock width8" placeholder="">
                                                        <c:if test="${index.index==0}">
                                                            <a class="btn btn-primary btn-sm addPeriod"
                                                               style="margin-left: 30px;margin-top: 3px">新增时段</a>
                                                        </c:if>
                                                        <c:if test="${index.index!=0}">
                                                            <a class="btn btn-danger btn-sm delTime_btn"
                                                               style="margin-left: 30px;margin-top: 3px">删除时段</a>
                                                        </c:if>
                                                    </div>
                                                </c:forEach>
                                            </c:if>
                                            <c:if test="${tenantDiscountPolicy.timeType eq '0'}">
                                                <div name="VIPQuantuan"
                                                     class="mt10 <c:if test="${tenantDiscountPolicy.timeType eq '0'}">hide</c:if>">
                                                    <label class="ml10" style="margin-left: 30px">时段1:</label>
                                                    <input id="D_startPeriod1" name="startPeriods" type="text"
                                                           autocomplete="off" value="00:00:00"
                                                           class="form-control ml10 inlineBlock width10" required
                                                           placeholder="开始时间">
                                                    <span class="mlr">--</span>
                                                    <input id="D_endPeriod1" name="endPeriods" type="text" required
                                                           autocomplete="off" value="00:59:59"
                                                           class="form-control inlineBlock width10" placeholder="结束时间">
                                                    <span class="ml10">服务费折扣*</span>
                                                    <input id="D_discounts1" name="discounts" type="text" required
                                                           autocomplete="off" value=""
                                                           class="form-control inlineBlock width8" placeholder="">
                                                    <a class="btn btn-primary btn-sm addPeriod"
                                                       style="margin-left: 30px;margin-top: 3px">新增时段</a>

                                                </div>
                                            </c:if>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <%--<c:if test="${tenantDiscountPolicy.discountType eq '1'}">--%>
                            <div class="typeBox2 <c:if test="${tenantDiscountPolicy.discountType eq '0'}">hide</c:if>">
                                <%--<h2>编辑时段价格</h2>--%>
                                <div class="row">
                                    <div class="col-lg-12">
                                        <div class="form-group disCountTypeBox1" style="display: block">
                                            <input type="radio" value="1" name="timeType"
                                                   <c:if test="${tenantDiscountPolicy.timeType eq '0'}">checked</c:if>
                                                   class="inlineBlock firstRadio"><label
                                                class="titleFont">采用全天标准优惠价</label>
                                            <c:if test="${tenantDiscountPolicy.timeType eq '0'}">
                                                <c:forEach items="${tenantDiscountPolicy.tenantDiscountTimeList}"
                                                           var="bean" varStatus="index" end="0">
                                                    <div class="typeTwoBox <c:if test="${tenantDiscountPolicy.timeType eq '1'}">hide</c:if>">
                                                        <span style="margin-left: 30px">电费优惠价</span>
                                                        <input id="" name="elecPrice0" type="text" required
                                                               value="${bean.elecPrice}"
                                                               class="form-control inlineBlock width20"
                                                               autocomplete="off"
                                                               placeholder="请输入电费优惠价">
                                                        <span class="ml-2">服务费优惠价</span>
                                                        <input id="" name="servicePrice0" type="text" required
                                                               value="${bean.servicePrice}"
                                                               class="form-control inlineBlock width20"
                                                               autocomplete="off"
                                                               placeholder="请输入服务优惠价">
                                                    </div>
                                                </c:forEach>
                                            </c:if>
                                            <c:if test="${tenantDiscountPolicy.timeType eq '1'}">
                                                <div class="typeTwoBox <c:if test="${tenantDiscountPolicy.timeType eq '1'}">hide</c:if>">
                                                    <span style="margin-left: 30px">电费优惠价</span>
                                                    <input id="" name="elecPrice0" type="text" required value=""
                                                           class="form-control inlineBlock width20" autocomplete="off"
                                                           placeholder="请输入电费优惠价">
                                                    <span class="ml-2">服务费优惠价</span>
                                                    <input id="" name="servicePrice0" type="text" required value=""
                                                           class="form-control inlineBlock width20" autocomplete="off"
                                                           placeholder="请输入服务优惠价">
                                                </div>
                                            </c:if>
                                        </div>

                                        <div class="form-group timeForm1" id="timeForm" style="display: block">
                                            <div>
                                                <input type="radio" value="2" name="timeType"
                                                       <c:if test="${tenantDiscountPolicy.timeType eq '1'}">checked</c:if>
                                                       class="inlineBlock secondRadio"><label
                                                    class="titleFont">采用分时段折扣设置（需覆盖全部时段）</label>
                                            </div>
                                            <c:if test="${tenantDiscountPolicy.timeType eq '1'}">
                                                <c:forEach items="${tenantDiscountPolicy.tenantDiscountTimeList}"
                                                           var="bean" varStatus="index">
                                                    <div name="VIPQuantuan"
                                                         class="mt10 <c:if test="${tenantDiscountPolicy.timeType eq '0'}">hide</c:if>">
                                                        <label class="ml10" style="margin-left: 30px">时段1:</label>
                                                        <input id="startPeriod${index.index+1}" name="startPeriod"
                                                               type="text"
                                                               autocomplete="off" required
                                                               value="<fmt:formatDate value="${not empty bean.beginTime?bean.beginTime:'00:00:00'}" pattern="HH:mm:ss" />"
                                                               class="form-control ml10 inlineBlock width10"
                                                               placeholder="开始时间">
                                                        <span class="mlr">--</span>
                                                        <input id="endPeriod${index.index+1}" name="endPeriod"
                                                               type="text"
                                                               autocomplete="off" required
                                                               value="<fmt:formatDate value="${not empty bean.endTime?bean.endTime:'00:59:59'}" pattern="HH:mm:ss" />"
                                                               class="form-control inlineBlock width10"
                                                               placeholder="结束时间">
                                                        <span class="ml10">电费优惠价*</span>
                                                        <input id="elecPrice${index.index+1}" name="elecPrice"
                                                               type="text"
                                                               autocomplete="off" required value="${bean.elecPrice}"
                                                               class="form-control inlineBlock width8" placeholder="">
                                                        <span class="ml10">服务费优惠价*</span>
                                                        <input id="servicePrice${index.index+1}" name="servicePrice"
                                                               type="text"
                                                               autocomplete="off" required value="${bean.servicePrice}"
                                                               class="form-control inlineBlock width8" placeholder="">
                                                        <c:if test="${index.index==0}">
                                                            <a class="btn btn-primary btn-sm addPeriod"
                                                               style="margin-left: 30px;margin-top: 3px">新增时段</a>
                                                        </c:if>
                                                        <c:if test="${index.index!=0}">
                                                            <a class="btn btn-danger btn-sm delTime_btn"
                                                               style="margin-left: 30px;margin-top: 3px">删除时段</a>
                                                        </c:if>
                                                    </div>
                                                </c:forEach>
                                            </c:if>
                                            <c:if test="${tenantDiscountPolicy.timeType eq '0'}">
                                                <div name="VIPQuantuan"
                                                     class="mt10 <c:if test="${tenantDiscountPolicy.timeType eq '0'}">hide</c:if>">
                                                    <label class="ml10" style="margin-left: 30px">时段1:</label>
                                                    <input id="startPeriod1" name="startPeriod" type="text"
                                                           autocomplete="off" required value="00:00:00"
                                                           class="form-control ml10 inlineBlock width10"
                                                           placeholder="开始时间">
                                                    <span class="mlr">--</span>
                                                    <input id="endPeriod1" name="endPeriod" type="text"
                                                           autocomplete="off" required value=""
                                                           class="form-control inlineBlock width10" placeholder="结束时间">
                                                    <span class="ml10">电费优惠价*</span>
                                                    <input id="elecPrice1" name="elecPrice" type="text"
                                                           autocomplete="off" required value="00:59:59"
                                                           class="form-control inlineBlock width8" placeholder="">
                                                    <span class="ml10">服务费优惠价*</span>
                                                    <input id="servicePrice1" name="servicePrice" type="text"
                                                           autocomplete="off" required value=""
                                                           class="form-control inlineBlock width8" placeholder="">
                                                    <a class="btn btn-primary btn-sm addPeriod"
                                                       style="margin-left: 30px;margin-top: 3px">新增时段</a>


                                                </div>
                                            </c:if>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <%--</c:if>--%>
                        </fieldset>
                        <%--<h1>用户</h1>--%>
                        <%--<fieldset>--%>
                        <%--<h2>折扣站点选择</h2>--%>
                        <%--<div class="pilesBox">--%>
                        <%--<ul class="pilesOne">--%>
                        <%--<h1><p class="pileType"><span class="drawBack"></span>自营</p><span class="pr" ><input class=" Allcheckbox" name="selectAll" type="checkbox" style="margin-right: 0">&nbsp;全选</span></h1>--%>
                        <%--</ul>--%>
                        <%--</div>--%>
                        <%--<div class="pilesBox">--%>
                        <%--<ul class="pilesTwo">--%>
                        <%--<h1><p class="pileType"><span class="drawBack"></span>非自营</p><span class="pr"><input class=" Allcheckbox" name="selectAll" type="checkbox" style="margin-right: 0">&nbsp;全选</span>--%>
                        <%--</h1>--%>
                        <%--</ul>--%>
                        <%--<!--<button id="btn">按钮</button>-->--%>
                        <%--</div>--%>
                        <%--&lt;%&ndash;<label for="acceptTerms">我同意条款和条件。</label>&ndash;%&gt;--%>
                        <%--</fieldset>--%>

                    </form>

                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="${ctx}/appjs/hlht/editHlhtDiscount.js"></script>
<script>
    $("#form").on("change", '[name="discountType"]', function () {
        if ($(this).val() == "0") {
            $(".typeBox1").removeClass("hide")
            $(".typeBox2").addClass("hide");

            // $(this).parents(".form-group").siblings("#timeForm").find("#addPeriod").css("display","none")
        } else {
            $(".typeBox1").addClass("hide")
            $(".typeBox2").removeClass("hide")
        }
        if ($(this).val() == "0" && ${tenantDiscountPolicy.discountType=="0"}) {
            $("[name=VIPQuantuan]").addClass("hide")
        } else if ($(this).val() == "0" && ${tenantDiscountPolicy.discountType=="1"}) {
            $(".typeBox1 [name='startPeriods']").val("")
            $(".typeBox1 [name='endPeriods']").val("")
            $(".typeBox1 [name='discounts']").val("")
            $("[name=VIPQuantuan]").addClass("hide")
            // $('input[name="elecPrice0"]').attr("disabled", "disabled");
            // $('input[name="servicePrice0"]').attr("disabled", "disabled");
            $(".typeTwoBox").removeClass("hide")
            $(".typeOneBox").removeClass("hide")
            $('.firstRadio').prop("checked", true)
            $('.secondRadio').prop("checked", false)
            $("[name=VIPQuantuan]").next().remove()
        } else if ($(this).val() == "1" && ${tenantDiscountPolicy.discountType=="0"}) {
            $("[name=VIPQuantuan]").addClass("hide")
            // $('input[name="elecPrice0"]').removeAttr("disabled");
            // $('input[name="servicePrice0"]').removeAttr("disabled");
            $(".typeTwoBox").removeClass("hide")
            $(".typeOneBox").removeClass("hide")
            $('.firstRadio').prop("checked", true)
            $('.secondRadio').prop("checked", false)
            $("[name=VIPQuantuan]").next().remove()
            $(".typeBox2 [name='startPeriod']").val("")
            $(".typeBox2 [name='endPeriod']").val("")
            $(".typeBox2 [name='elecPrice']").val("")
            $(".typeBox2 [name='servicePrice']").val("")
        } else if ($(this).val() == "1" && ${tenantDiscountPolicy.discountType=="1"}) {
            $("[name=VIPQuantuan]").addClass("hide")
        }
    })
</script>
</html>
